package com.practice.library.Dao;

import com.practice.library.Model.BookInfo;
import org.springframework.stereotype.Repository;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;
@Repository
@RequestMapping("/book")
public class BookDao {
    //数据mock,还未学习数据库,暂时使用模拟的方式存储数据
    public List<BookInfo> mockData() {
        List<BookInfo> bookInfos = new ArrayList<>();
        for (int i = 0; i < 15; i++) {
            BookInfo bookInfo = new BookInfo();
            bookInfo.setBookId(i);
            bookInfo.setBookName("图书" + i);
            bookInfo.setAuthor("作者" + i);
            bookInfo.setNum(15 * i + 1);
            bookInfo.setPrice(new BigDecimal(21*i-13*i+14));
            bookInfo.setPublishName("出版社" + i);
            bookInfo.setState(i % 5 == 0 ? 2 : 1);
            bookInfos.add(bookInfo);
        }
        return bookInfos;
    }
}
